import request from '@/utils/request.js'

export const  flowNodes = ref([]);
export const  flowEdges = ref([]);
export const llmModelList = ref([])
export const knowledgeList = ref([])
export const canSaveFlag = ref(true)

// 查询AI流程列表
export function listAiWorkflow(query) {
    return request({
        url: '/ai/aiWorkflow/list',
        method: 'post',
        data: query
    })
}

export function listAllRelease() {
    return  request({
        url: '/ai/aiWorkflow/listAllRelease',
        method: 'get'
    })
}

// 查询AI流程详细
export function getAiWorkflow(id) {
    return request({
        url: '/ai/aiWorkflow/detail/' + id,
        method: 'get'
    })
}

// 新增AI流程
export function addAiWorkflow(data) {
    return request({
        url: '/ai/aiWorkflow/save',
        method: 'post',
        data: data
    })
}

// 修改AI流程
export function updateAiWorkflow(data) {
    return request({
        url: '/ai/aiWorkflow/update',
        method: 'put',
        data: data
    })
}

// 删除AI流程
export function delAiWorkflow(id) {
    return request({
        url: '/ai/aiWorkflow/remove/' + id,
        method: 'delete'
    })
}

export function releaseAiWorkflow(id) {
    return request({
        url: '/ai/aiWorkflow/release/' + id,
        method: 'put'
    })
}

export function designAiWorkflow(id, graph) {
    console.log(id)
    console.log(graph)
    return request({
        url: '/ai/aiWorkflow/design',
        method: 'put',
        data: {id, graph}
    })
}

export function excWorkflow(graph, params, customType) {
    return request({
        url: '/ai/aiWorkflow/execute',
        method: 'post',
        timeout: 6000000,
        data: {graph, params, customType}
    })
}